<template>
  <!-- header -->
  <div class="nav-container1 page-component">

    <!-- 右侧内容 #start -->
    <div class="page-container">
      <div class="personal-order">
        <!-- <div class="title"> 挂号订单</div> -->
        <el-form :inline="true">
          <el-form-item label="订单状态：">
            <el-select v-model="searchObj.orderStatus" placeholder="全部" class="v-select patient-select" style="width: 200px;">
              <el-option
                v-for="item in statusList"
                :key="item.status"
                :label="item.comment"
                :value="item.status">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="订单号" >
             <el-input v-model="searchObj.outTradeNo" placeholder="请输入订单号"></el-input>
          </el-form-item>
          <el-form-item label="订单时间">
              <el-date-picker
                v-model="value1"
                type="date"
                placeholder="开始">
              </el-date-picker>
              至
              <el-date-picker
                v-model="value1"
                type="date"
                placeholder="结束">
              </el-date-picker>
          </el-form-item>
          <el-form-item label="医院名称" >
             <el-input v-model="searchObj.keyword"  placeholder="请输入医院名称"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="text" class="search-button v-link highlight clickable selected" @click="fetchData(1)">
              查询
            </el-button>
            <el-button type="text" class="search-button v-link highlight clickable " @click="resetDate()">
              重置
            </el-button>
          </el-form-item>
        </el-form>
        <div class="table-wrapper table">
          <el-table
            :data="list"
            stripe
            style="width: 100%">
            <el-table-column
              label="序号"
              width="60"
              align="center">
                  <template slot-scope="scope">
                          {{ (page - 1) * limit + scope.$index + 1 }}
                  </template>
              </el-table-column>

            <el-table-column
              label="就诊时间"
              width="150">
              <template slot-scope="scope">
                {{ scope.row.reserveDate }} {{ scope.row.reserveTime === 0 ? '上午' : '下午' }}
              </template>
            </el-table-column>
            <el-table-column
              prop="hosname"
              label="医院"
              width="150">
            </el-table-column>
            <el-table-column
              prop="depname"
              label="科室"
              width="180">
            </el-table-column>
            <el-table-column
              prop="title"
              label="医生">
            </el-table-column>
            <el-table-column
              prop="amount"
              label="医事服务费">
            </el-table-column>
            <el-table-column
              prop="patientName"
              label="就诊人">
            </el-table-column>
            <el-table-column
              prop="param.orderStatusString"
              label="订单状态">
            </el-table-column>
            <el-table-column label="操作">
              <template slot-scope="scope">
                <el-button type="text" class="v-link highlight clickable selected" @click="show(scope.row.id)">详情</el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <!-- 分页 -->
        <el-pagination
          @size-change="changeSize"
          @current-change="fetchData"
          :current-page="page"
          :page-sizes="[5, 10, 15, 20]"
          :page-size="limit"
          align="center"
          :hide-on-single-page="singlePage"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total">
        </el-pagination>
      </div>
    </div>
    <!-- 右侧内容 #end -->
  </div>
  <!-- footer -->
</template>
<script>
// import '@/assets/css/hospital_personal.css'
// import '@/assets/css/hospital.css'
import orderInfoApi from '@/api/order/orderInfo.js'
export default {
  data() {
    return {
      list: [], // banner列表
      total: 0, // 数据库中的总记录数
      page: 1, // 默认页码
      limit: 10, // 每页记录数
      searchObj: {}, // 查询表单对象
      statusList: [],
      singlePage:true
    }
  },
  created() {
    this.fetchData(1)
    this.getStatusList()
  },
  methods: {
    fetchData(page) {
      this.page = page
      orderInfoApi.getPageList(this.page, this.limit, this.searchObj).then(response => {
        this.list = response.data.records
        this.total = response.data.total
      })
    },
    getStatusList() {
      orderInfoApi.getStatusList().then(response => {
        this.statusList = response.data
      })
    },
    changeSize(size) {
      this.limit = size
      this.fetchData(1)
    },
    show(id) {
      this.$router.push({path:'/order/orderInfo/show/'+id})
    },
    resetDate(){
      this.searchObj = {}
      this.fetchData(1)
    }
  }
}
</script>
